FirstCtrl = {};
local this = FirstCtrl;

local message;
local transform;
local gameObject;

--构建函数--
function FirstCtrl.New()
    logWarn("FirstCtrl.New--->>");
    return this;
end

function FirstCtrl.Awake()
    logWarn("FirstCtrl.Awake--->>");
    panelMgr:CreatePanel('First', this.OnCreate);
end

--启动事件--
function FirstCtrl.OnCreate(obj)
    gameObject = obj;
    transform = obj.transform;

    message = gameObject:GetComponent('LuaBehaviour');

    --这句要注释掉，因为我们的FirstPanel中没有按钮
    --message:AddClick(MessagePanel.btnClose, this.OnClick);

    resMgr:LoadPrefab("prefabs.unity3d", {"ImgOrc"}, function (prefabs)
        log(prefabs.Length);
        log(prefabs[0].name);

        --加载兽人头像
        local go = newObject(prefabs[0]);
        go.transform:SetParent(transform);
        go.transform.localPosition = Vector3.zero;
        go.transform.localScale = Vector3.one;

    end);

    resMgr:LoadPrefab("prefabs.unity3d", {"ButtonPrefab"}, function (prefabs)
        local go = newObject(prefabs[0]);
        go.transform:SetParent(transform);
        go.transform.localPosition = Vector3.one;
        go.transform.localScale = Vector3.one;
        message:AddClick(go, function ()
            log("你点击了关闭");
        end);
    end);



    logWarn("Start lua--->>"..gameObject.name);
end

--单击事件--
function FirstCtrl.OnClick(go)
    destroy(gameObject);
end

--关闭事件--
function FirstCtrl.Close()
    panelMgr:ClosePanel(CtrlNames.Message);
end